Skip to content

Conversation

@hrshya
Copy link
Contributor

@hrshya hrshya commented Jan 3, 2026

Resolves none .

Description

What is the purpose of this pull request?

This pull request:

  • Adds the complete implementation for math/base/special/atanhf .

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review. labels Jan 3, 2026
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Jan 3, 2026

Coverage Report

Package Statements Branches Functions Lines
math/base/special/atanhf $\color{green}255/255$
$\color{green}+0.00%$
$\color{green}24/24$
$\color{green}+0.00%$
$\color{green}2/2$
$\color{green}+0.00%$
$\color{green}255/255$
$\color{green}+0.00%$

The above coverage report was generated for the changes in this PR.

@hrshya
Copy link
Contributor Author

hrshya commented Jan 3, 2026

/stdlib lint-autofix

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Jan 3, 2026
@stdlib-bot
Copy link
Contributor

/stdlib lint-autofix

@hrshya, the slash command failed to complete. Please check the workflow logs for details.

View workflow run

@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Jan 3, 2026
@hrshya hrshya requested review from anandkaranubc and kgryte January 3, 2026 12:31
*/
static double benchmark( void ) {
double elapsed;
double x;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variables x and y declared as double instead of float here.

// VARIABLES //

var opts = {
'skip': ( typeof Math.atanhf !== 'function' ) // eslint-disable-line stdlib/no-builtin-math
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Math.atanhf does not exist. Can only compare to Math.atanh.

#include "stdlib/constants/float32/ninf.h"
#include <stdint.h>

static const float NEAR_ZERO = 1.0 / (1 << 28); // 2**-28
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static const float NEAR_ZERO = 1.0 / (1 << 28); // 2**-28
static const float NEAR_ZERO = 1.0f / (1 << 28); // 2**-28

int i;
for ( i = 0; i < 10; i++ ) {
v = stdlib_base_atanhf( x[ i ] );
printf( "atanhf(%lf) = %lf\n", x[ i ], v );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use %f instead of %lf.

@Planeshifter Planeshifter added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Jan 7, 2026
@hrshya hrshya requested a review from Planeshifter January 7, 2026 10:02
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jan 7, 2026
t.strictEqual( y, e, 'x: '+x[i]+'. E: '+e );
} else {
delta = abs( y - e );
tol = 1.3 * EPS * abs( e );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there are reason why the "small negative" test case uses 1.3 * EPS here but 1.0 * EPS in test.js line 123?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out, that was not intentional

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: passed
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
Comment on lines 77 to 85
/**
* Generates a random number on the interval [0,1).
*
* @return random number
*/
static float rand_float( void ) {
int r = rand();
return (float)r / ( (float)RAND_MAX + 1.0f );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this to use random_uniform instead? You can refer to tanf for this

Comment on lines 101 to 102
x = ( 2.0f * rand_float() ) - 1.0f;
y = stdlib_base_atanhf( x );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done outside the loop. tanf is a good example to refer to.

*
* @return random number
*/
static float rand_float( void ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment applies here and below, for random number generation.

Comment on lines 67 to 73
if ( y === e ) {
t.strictEqual( y, e, 'x: '+x[i]+'. E: '+e );
} else {
delta = abs( y - e );
tol = 1.3 * EPS * abs( e );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. tol: '+tol+'.' );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you refactor this to use assert/is-almost-same-value instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment applies below and for test.native.js

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: passed
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: passed
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
Comment on lines 67 to 73
if ( y === e ) {
t.strictEqual( y, e, 'x: '+x[i]+'. E: '+e );
} else {
delta = abs( y - e );
tol = 1.3 * EPS * abs( e );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. tol: '+tol+'.' );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment applies below and for test.native.js

@anandkaranubc anandkaranubc added Feature Issue or pull request for adding a new feature. JavaScript Issue involves or relates to JavaScript. C Issue involves or relates to C. and removed Needs Review A pull request which needs code review. labels Jan 8, 2026
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jan 13, 2026
@hrshya hrshya closed this Jan 15, 2026
@hrshya hrshya deleted the feat/atanhf branch January 15, 2026 10:46
@hrshya hrshya restored the feat/atanhf branch January 15, 2026 10:46
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Jan 15, 2026
@hrshya hrshya reopened this Jan 15, 2026
Signed-off-by: Philipp Burckhardt <[email protected]>
Copy link
Member

@Planeshifter Planeshifter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Planeshifter Planeshifter added the Ready To Merge A pull request which is ready to be merged. label Jan 16, 2026
@stdlib-bot stdlib-bot removed the Needs Changes Pull request which needs changes before being merged. label Jan 16, 2026
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Jan 16, 2026

PR Commit Message

feat: add `math/base/special/atanhf`

PR-URL: https://github.com/stdlib-js/stdlib/pull/9514
Ref: https://github.com/stdlib-js/stdlib/issues/649

Co-authored-by: Karan Anand <[email protected]>
Co-authored-by: Philipp Burckhardt <[email protected]>
Reviewed-by: Philipp Burckhardt <[email protected]>
Reviewed-by: Karan Anand <[email protected]>
Reviewed-by: Athan Reines <[email protected]>
Signed-off-by: Harsh <[email protected]>
Signed-off-by: Philipp Burckhardt <[email protected]>

Please review the above commit message and make any necessary adjustments.

⚠️ Action Required: This PR references tracking issues. Please update the PR description to replace any "Closes", "Fixes", or "Resolves" keywords with "Ref" when referencing these issues.

@Planeshifter Planeshifter merged commit 7f68fc4 into stdlib-js:develop Jan 16, 2026
31 checks passed
@stdlib-bot stdlib-bot removed the Ready To Merge A pull request which is ready to be merged. label Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C Issue involves or relates to C. Feature Issue or pull request for adding a new feature. JavaScript Issue involves or relates to JavaScript. Math Issue or pull request specific to math functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants